package com.example.demo.controller.impl;
import com.example.demo.controller.DeptController;
import com.example.demo.pojo.Dept;
import com.example.demo.pojo.Result;
import com.example.demo.service.impl.addDeptServiceImpl;
import jakarta.servlet.http.PushBuilder;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

//@RestController
@Controller
@ResponseBody
public class DeptControllerImpl implements DeptController {
    @Autowired
    addDeptServiceImpl addDeptService;
    @GetMapping("/addinfo")
    @Override
    public String addController() {
        String ask = addDeptService.addDeptService("用户来请求啦");
        //寻找业务逻辑层
        return ask;
    }
    @GetMapping("/dept")
    public Result list()
    {
        return Result.success(addDeptService.selectAllService());

    }
    @DeleteMapping("/dept/{id}")
    public Result delete(@PathVariable  Integer id){
        addDeptService.deleteAllService(id);
        return Result.success();
   }
    @PostMapping("/dept")
    public Result add(@RequestBody Dept dept){
        addDeptService.addService(dept);
        return Result.success();
    }

}
